const query = "user=abc&pwd=123"

const params = new URLSearchParams(query);
console.log(params.entries());

const str = "user=abc&pwd=123&hobby=读书&hobby=写作"
var arr = str.split("&")
var obj = {}
for(item of arr){
    var arr1 = item.split("=");
    var key = arr1[0];
    var val = arr1[1];
    if(key in obj ){
        obj[key].push(val)
    }else{
        obj[key]=[val]
    }
}
console.log(obj);